﻿<UserControl x:Class="AppCommerciaux.Views.LigneCommandeEditView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:converters="clr-namespace:AppCommerciaux.converter"
             mc:Ignorable="d" 
             d:DesignHeight="545" d:DesignWidth="1010">
    <UserControl.Resources>
        <converters:produitToStringValueConverter x:Key="produitToStringValueConverter" />
        <converters:tvaToStringValueConverter x:Key="tvaToStringValueConverter" />
        <converters:uniteToStringValueConverter x:Key="uniteToStringValueConverter" />
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="60" />
            <RowDefinition Height="300" />
            <RowDefinition Height="50" />
            <RowDefinition Height="60" />
            <RowDefinition Height="60" />
            <RowDefinition Height="50" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="70"/>
            <ColumnDefinition Width="430"/>
            <ColumnDefinition Width="300"/>
            <ColumnDefinition Width="300"/>
        </Grid.ColumnDefinitions>

        <TextBlock
            Grid.ColumnSpan="4"
            Text="{Binding Titre}" Margin="32,19,268,281" Grid.RowSpan="2"/>

        <Button Content="Valider" 
                Grid.Column="2" HorizontalAlignment="Left" Height="23" Margin="0,35,0,0" Grid.Row="3" VerticalAlignment="Top" Width="91" Command="{Binding BoutonOk}"/>


        <Button Content="Annuler" 
                Grid.Column="2" HorizontalAlignment="Left" Height="23" Margin="114,35,0,0" Grid.Row="3" VerticalAlignment="Top" Width="102" Command="{Binding BoutonRetour}"/>


        <Label Content="Produit :" HorizontalAlignment="Left" Margin="401,118,0,0" Grid.Row="1" VerticalAlignment="Top" Width="58" Grid.Column="1" Height="26" Grid.ColumnSpan="2"/>
        <Label Content="Quantité :" HorizontalAlignment="Left" Margin="392,156,0,0" Grid.Row="1" VerticalAlignment="Top" Width="67" Grid.Column="1" Height="26" Grid.ColumnSpan="2"/>



        <TextBox x:Name="QuantiteTextBox"
                 Grid.Column="2" HorizontalAlignment="Left" Height="23" Margin="61,159,0,0" Grid.Row="1" TextWrapping="Wrap" 
                 Text="{Binding SelectedLigneCommande.quantite,
                                        UpdateSourceTrigger=PropertyChanged}" 
                 TextChanged="txtnumber_TextChanged"
                 MaxLength="4"
                 VerticalAlignment="Top" Width="155"/>




        <ComboBox x:Name="ProduitCombobox" 
                  ItemsSource="{Binding ListProduit}"
                  SelectedItem="{Binding SelectedProduit, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                  Grid.Column="2" HorizontalAlignment="Left" Margin="61,122,0,0" Grid.Row="1" VerticalAlignment="Top" Width="155" Height="22">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Converter={StaticResource produitToStringValueConverter}}"/>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>
        <Label Content="Détails du produit sélectionné" HorizontalAlignment="Left" Margin="60,63,0,0" Grid.Row="1" VerticalAlignment="Top" Grid.Column="1" Height="34" Width="292" FontSize="18"/>


        <Label Content="Qté en stock :" 
               HorizontalAlignment="Left" Margin="43,222,0,0" Grid.Row="1" VerticalAlignment="Top" Grid.Column="1" Height="26" Width="83"/>
        <TextBox x:Name="QteStock" 
                 IsReadOnly="True"
                 Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="156,224,0,0" Grid.Row="1" TextWrapping="Wrap" 
                 Text="{Binding SelectedLigneCommande.produit.stock_en_cours, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="120"/>



        <Label Content="Id :" 
               Grid.Column="1" HorizontalAlignment="Left" Margin="105,112,0,0" Grid.Row="1" VerticalAlignment="Top"/>
        <TextBox x:Name="IdProduitTextBox" Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="156,112,0,0" Grid.Row="1" TextWrapping="Wrap" 
                 Text="{Binding SelectedLigneCommande.produit.id}" IsReadOnly="True"
                 VerticalAlignment="Top" Width="120"/>


        <Label Content="Prix unitaire :" 
               Grid.Column="1" HorizontalAlignment="Left" Margin="48,140,0,0" Grid.Row="1" VerticalAlignment="Top"/>
        <TextBox x:Name="PuProduitTextBox" Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="156,140,0,0" Grid.Row="1" TextWrapping="Wrap" 
                 Text="{Binding SelectedLigneCommande.produit.pu}" IsReadOnly="True"
                 VerticalAlignment="Top" Width="120"/>


        <Label Content="Unité de mesure :" 
               Grid.Column="1" HorizontalAlignment="Left" Margin="23,168,0,0" Grid.Row="1" VerticalAlignment="Top"/>
        <TextBox x:Name="uniteProduitTextBox" 
                 Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="156,168,0,0" Grid.Row="1" TextWrapping="Wrap" 
                 Text="{Binding SelectedLigneCommande.produit.unite,Converter={StaticResource uniteToStringValueConverter}}" IsReadOnly="True"
                 VerticalAlignment="Top" Width="120"/>


        <Label x:Name="tvaProduitTextBox" 
               Content="TVA (%):" Grid.Column="1" HorizontalAlignment="Left" Margin="72,196,0,0" Grid.Row="1" VerticalAlignment="Top"/>
        <TextBox Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="156,196,0,0" Grid.Row="1" TextWrapping="Wrap" 
                 Text="{Binding SelectedLigneCommande.produit.tva,Converter={StaticResource tvaToStringValueConverter}}" IsReadOnly="True"
                 VerticalAlignment="Top" Width="120"/>
        <DockPanel Grid.Column="1" HorizontalAlignment="Left" Height="228" LastChildFill="False" Margin="0,50,0,0" Grid.Row="1" VerticalAlignment="Top" Width="352" Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}" Panel.ZIndex="-1"/>



    </Grid>

</UserControl>
